/** @file
 *    @brief MAVLink comm protocol testsuite generated from equipment.xml
 *    @see http://qgroundcontrol.org/mavlink/
 */
#pragma once
#ifndef EQUIPMENT_TESTSUITE_H
#define EQUIPMENT_TESTSUITE_H

#ifdef __cplusplus
extern "C" {
#endif

#ifndef MAVLINK_TEST_ALL
#define MAVLINK_TEST_ALL

static void mavlink_test_equipment(uint8_t, uint8_t, mavlink_message_t *last_msg);

static void mavlink_test_all(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
{

    mavlink_test_equipment(system_id, component_id, last_msg);
}
#endif




static void mavlink_test_gyroscope(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
{
#ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
    mavlink_status_t *status = mavlink_get_channel_status(MAVLINK_COMM_0);
        if ((status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) && MAVLINK_MSG_ID_Gyroscope >= 256) {
            return;
        }
#endif
    mavlink_message_t msg;
        uint8_t buffer[MAVLINK_MAX_PACKET_LEN];
        uint16_t i;
    mavlink_gyroscope_t packet_in = {
        963497464,963497672,963497880,963498088,963498296,963498504,963498712,963498920
    };
    mavlink_gyroscope_t packet1, packet2;
        memset(&packet1, 0, sizeof(packet1));
        packet1.gytempreture = packet_in.gytempreture;
        packet1.gylingdata = packet_in.gylingdata;
        packet1.qystartdata = packet_in.qystartdata;
        packet1.gylvdata = packet_in.gylvdata;
        packet1.gyangle = packet_in.gyangle;
        packet1.gyP = packet_in.gyP;
        packet1.gyQ = packet_in.gyQ;
        packet1.gyR = packet_in.gyR;
        
        
#ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
        if (status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) {
           // cope with extensions
           memset(MAVLINK_MSG_ID_Gyroscope_MIN_LEN + (char *)&packet1, 0, sizeof(packet1)-MAVLINK_MSG_ID_Gyroscope_MIN_LEN);
        }
#endif
        memset(&packet2, 0, sizeof(packet2));
    mavlink_msg_gyroscope_encode(system_id, component_id, &msg, &packet1);
    mavlink_msg_gyroscope_decode(&msg, &packet2);
        MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);

        memset(&packet2, 0, sizeof(packet2));
    mavlink_msg_gyroscope_pack(system_id, component_id, &msg , packet1.gytempreture , packet1.gylingdata , packet1.qystartdata , packet1.gylvdata , packet1.gyangle , packet1.gyP , packet1.gyQ , packet1.gyR );
    mavlink_msg_gyroscope_decode(&msg, &packet2);
        MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);

        memset(&packet2, 0, sizeof(packet2));
    mavlink_msg_gyroscope_pack_chan(system_id, component_id, MAVLINK_COMM_0, &msg , packet1.gytempreture , packet1.gylingdata , packet1.qystartdata , packet1.gylvdata , packet1.gyangle , packet1.gyP , packet1.gyQ , packet1.gyR );
    mavlink_msg_gyroscope_decode(&msg, &packet2);
        MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);

        memset(&packet2, 0, sizeof(packet2));
        mavlink_msg_to_send_buffer(buffer, &msg);
        for (i=0; i<mavlink_msg_get_send_buffer_length(&msg); i++) {
            comm_send_ch(MAVLINK_COMM_0, buffer[i]);
        }
    mavlink_msg_gyroscope_decode(last_msg, &packet2);
        MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
        
        memset(&packet2, 0, sizeof(packet2));
    mavlink_msg_gyroscope_send(MAVLINK_COMM_1 , packet1.gytempreture , packet1.gylingdata , packet1.qystartdata , packet1.gylvdata , packet1.gyangle , packet1.gyP , packet1.gyQ , packet1.gyR );
    mavlink_msg_gyroscope_decode(last_msg, &packet2);
        MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
}

static void mavlink_test_magnetometer(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
{
#ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
    mavlink_status_t *status = mavlink_get_channel_status(MAVLINK_COMM_0);
        if ((status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) && MAVLINK_MSG_ID_Magnetometer >= 256) {
            return;
        }
#endif
    mavlink_message_t msg;
        uint8_t buffer[MAVLINK_MAX_PACKET_LEN];
        uint16_t i;
    mavlink_magnetometer_t packet_in = {
        963497464,963497672,963497880,963498088,963498296,963498504,963498712,963498920,963499128,963499336,963499544,963499752
    };
    mavlink_magnetometer_t packet1, packet2;
        memset(&packet1, 0, sizeof(packet1));
        packet1.ma = packet_in.ma;
        packet1.malvX = packet_in.malvX;
        packet1.mastartY = packet_in.mastartY;
        packet1.malvY = packet_in.malvY;
        packet1.maAngle = packet_in.maAngle;
        packet1.maNumber = packet_in.maNumber;
        packet1.malingX = packet_in.malingX;
        packet1.malingY = packet_in.malingY;
        packet1.mascircle = packet_in.mascircle;
        packet1.gyP = packet_in.gyP;
        packet1.gyQ = packet_in.gyQ;
        packet1.gyR = packet_in.gyR;
        
        
#ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
        if (status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) {
           // cope with extensions
           memset(MAVLINK_MSG_ID_Magnetometer_MIN_LEN + (char *)&packet1, 0, sizeof(packet1)-MAVLINK_MSG_ID_Magnetometer_MIN_LEN);
        }
#endif
        memset(&packet2, 0, sizeof(packet2));
    mavlink_msg_magnetometer_encode(system_id, component_id, &msg, &packet1);
    mavlink_msg_magnetometer_decode(&msg, &packet2);
        MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);

        memset(&packet2, 0, sizeof(packet2));
    mavlink_msg_magnetometer_pack(system_id, component_id, &msg , packet1.ma , packet1.malvX , packet1.mastartY , packet1.malvY , packet1.maAngle , packet1.maNumber , packet1.malingX , packet1.malingY , packet1.mascircle , packet1.gyP , packet1.gyQ , packet1.gyR );
    mavlink_msg_magnetometer_decode(&msg, &packet2);
        MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);

        memset(&packet2, 0, sizeof(packet2));
    mavlink_msg_magnetometer_pack_chan(system_id, component_id, MAVLINK_COMM_0, &msg , packet1.ma , packet1.malvX , packet1.mastartY , packet1.malvY , packet1.maAngle , packet1.maNumber , packet1.malingX , packet1.malingY , packet1.mascircle , packet1.gyP , packet1.gyQ , packet1.gyR );
    mavlink_msg_magnetometer_decode(&msg, &packet2);
        MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);

        memset(&packet2, 0, sizeof(packet2));
        mavlink_msg_to_send_buffer(buffer, &msg);
        for (i=0; i<mavlink_msg_get_send_buffer_length(&msg); i++) {
            comm_send_ch(MAVLINK_COMM_0, buffer[i]);
        }
    mavlink_msg_magnetometer_decode(last_msg, &packet2);
        MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
        
        memset(&packet2, 0, sizeof(packet2));
    mavlink_msg_magnetometer_send(MAVLINK_COMM_1 , packet1.ma , packet1.malvX , packet1.mastartY , packet1.malvY , packet1.maAngle , packet1.maNumber , packet1.malingX , packet1.malingY , packet1.mascircle , packet1.gyP , packet1.gyQ , packet1.gyR );
    mavlink_msg_magnetometer_decode(last_msg, &packet2);
        MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
}

static void mavlink_test_allinlast(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
{
#ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
    mavlink_status_t *status = mavlink_get_channel_status(MAVLINK_COMM_0);
        if ((status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) && MAVLINK_MSG_ID_AllinLast >= 256) {
            return;
        }
#endif
    mavlink_message_t msg;
        uint8_t buffer[MAVLINK_MAX_PACKET_LEN];
        uint16_t i;
    mavlink_allinlast_t packet_in = {
        963497464,963497672,963497880,963498088
    };
    mavlink_allinlast_t packet1, packet2;
        memset(&packet1, 0, sizeof(packet1));
        packet1.allangle = packet_in.allangle;
        packet1.allX = packet_in.allX;
        packet1.allY = packet_in.allY;
        packet1.allziangle = packet_in.allziangle;
        
        
#ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
        if (status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) {
           // cope with extensions
           memset(MAVLINK_MSG_ID_AllinLast_MIN_LEN + (char *)&packet1, 0, sizeof(packet1)-MAVLINK_MSG_ID_AllinLast_MIN_LEN);
        }
#endif
        memset(&packet2, 0, sizeof(packet2));
    mavlink_msg_allinlast_encode(system_id, component_id, &msg, &packet1);
    mavlink_msg_allinlast_decode(&msg, &packet2);
        MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);

        memset(&packet2, 0, sizeof(packet2));
    mavlink_msg_allinlast_pack(system_id, component_id, &msg , packet1.allangle , packet1.allX , packet1.allY , packet1.allziangle );
    mavlink_msg_allinlast_decode(&msg, &packet2);
        MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);

        memset(&packet2, 0, sizeof(packet2));
    mavlink_msg_allinlast_pack_chan(system_id, component_id, MAVLINK_COMM_0, &msg , packet1.allangle , packet1.allX , packet1.allY , packet1.allziangle );
    mavlink_msg_allinlast_decode(&msg, &packet2);
        MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);

        memset(&packet2, 0, sizeof(packet2));
        mavlink_msg_to_send_buffer(buffer, &msg);
        for (i=0; i<mavlink_msg_get_send_buffer_length(&msg); i++) {
            comm_send_ch(MAVLINK_COMM_0, buffer[i]);
        }
    mavlink_msg_allinlast_decode(last_msg, &packet2);
        MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
        
        memset(&packet2, 0, sizeof(packet2));
    mavlink_msg_allinlast_send(MAVLINK_COMM_1 , packet1.allangle , packet1.allX , packet1.allY , packet1.allziangle );
    mavlink_msg_allinlast_decode(last_msg, &packet2);
        MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
}

static void mavlink_test_modechoose(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
{
#ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
    mavlink_status_t *status = mavlink_get_channel_status(MAVLINK_COMM_0);
        if ((status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) && MAVLINK_MSG_ID_ModeChoose >= 256) {
            return;
        }
#endif
    mavlink_message_t msg;
        uint8_t buffer[MAVLINK_MAX_PACKET_LEN];
        uint16_t i;
    mavlink_modechoose_t packet_in = {
        963497464
    };
    mavlink_modechoose_t packet1, packet2;
        memset(&packet1, 0, sizeof(packet1));
        packet1.mode = packet_in.mode;
        
        
#ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
        if (status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) {
           // cope with extensions
           memset(MAVLINK_MSG_ID_ModeChoose_MIN_LEN + (char *)&packet1, 0, sizeof(packet1)-MAVLINK_MSG_ID_ModeChoose_MIN_LEN);
        }
#endif
        memset(&packet2, 0, sizeof(packet2));
    mavlink_msg_modechoose_encode(system_id, component_id, &msg, &packet1);
    mavlink_msg_modechoose_decode(&msg, &packet2);
        MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);

        memset(&packet2, 0, sizeof(packet2));
    mavlink_msg_modechoose_pack(system_id, component_id, &msg , packet1.mode );
    mavlink_msg_modechoose_decode(&msg, &packet2);
        MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);

        memset(&packet2, 0, sizeof(packet2));
    mavlink_msg_modechoose_pack_chan(system_id, component_id, MAVLINK_COMM_0, &msg , packet1.mode );
    mavlink_msg_modechoose_decode(&msg, &packet2);
        MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);

        memset(&packet2, 0, sizeof(packet2));
        mavlink_msg_to_send_buffer(buffer, &msg);
        for (i=0; i<mavlink_msg_get_send_buffer_length(&msg); i++) {
            comm_send_ch(MAVLINK_COMM_0, buffer[i]);
        }
    mavlink_msg_modechoose_decode(last_msg, &packet2);
        MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
        
        memset(&packet2, 0, sizeof(packet2));
    mavlink_msg_modechoose_send(MAVLINK_COMM_1 , packet1.mode );
    mavlink_msg_modechoose_decode(last_msg, &packet2);
        MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
}

static void mavlink_test_control(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
{
#ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
    mavlink_status_t *status = mavlink_get_channel_status(MAVLINK_COMM_0);
        if ((status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) && MAVLINK_MSG_ID_Control >= 256) {
            return;
        }
#endif
    mavlink_message_t msg;
        uint8_t buffer[MAVLINK_MAX_PACKET_LEN];
        uint16_t i;
    mavlink_control_t packet_in = {
        963497464,963497672,963497880,963498088,963498296,963498504,963498712,18691,18795,18899,19003,19107,19211,19315,19419
    };
    mavlink_control_t packet1, packet2;
        memset(&packet1, 0, sizeof(packet1));
        packet1.cogoallocation = packet_in.cogoallocation;
        packet1.coactuallocation = packet_in.coactuallocation;
        packet1.cogoalangle = packet_in.cogoalangle;
        packet1.coactualangle = packet_in.coactualangle;
        packet1.coX = packet_in.coX;
        packet1.coY = packet_in.coY;
        packet1.coangle = packet_in.coangle;
        packet1.cogoalspeed = packet_in.cogoalspeed;
        packet1.coactualspeed = packet_in.coactualspeed;
        packet1.cogoalaccel = packet_in.cogoalaccel;
        packet1.coactualaccel = packet_in.coactualaccel;
        packet1.cogoalspinspeed = packet_in.cogoalspinspeed;
        packet1.coactualspinspeed = packet_in.coactualspinspeed;
        packet1.cogoalspinaccel = packet_in.cogoalspinaccel;
        packet1.coactualspinaccel = packet_in.coactualspinaccel;
        
        
#ifdef MAVLINK_STATUS_FLAG_OUT_MAVLINK1
        if (status->flags & MAVLINK_STATUS_FLAG_OUT_MAVLINK1) {
           // cope with extensions
           memset(MAVLINK_MSG_ID_Control_MIN_LEN + (char *)&packet1, 0, sizeof(packet1)-MAVLINK_MSG_ID_Control_MIN_LEN);
        }
#endif
        memset(&packet2, 0, sizeof(packet2));
    mavlink_msg_control_encode(system_id, component_id, &msg, &packet1);
    mavlink_msg_control_decode(&msg, &packet2);
        MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);

        memset(&packet2, 0, sizeof(packet2));
    mavlink_msg_control_pack(system_id, component_id, &msg , packet1.cogoallocation , packet1.coactuallocation , packet1.cogoalangle , packet1.coactualangle , packet1.coX , packet1.coY , packet1.coangle , packet1.cogoalspeed , packet1.coactualspeed , packet1.cogoalaccel , packet1.coactualaccel , packet1.cogoalspinspeed , packet1.coactualspinspeed , packet1.cogoalspinaccel , packet1.coactualspinaccel );
    mavlink_msg_control_decode(&msg, &packet2);
        MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);

        memset(&packet2, 0, sizeof(packet2));
    mavlink_msg_control_pack_chan(system_id, component_id, MAVLINK_COMM_0, &msg , packet1.cogoallocation , packet1.coactuallocation , packet1.cogoalangle , packet1.coactualangle , packet1.coX , packet1.coY , packet1.coangle , packet1.cogoalspeed , packet1.coactualspeed , packet1.cogoalaccel , packet1.coactualaccel , packet1.cogoalspinspeed , packet1.coactualspinspeed , packet1.cogoalspinaccel , packet1.coactualspinaccel );
    mavlink_msg_control_decode(&msg, &packet2);
        MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);

        memset(&packet2, 0, sizeof(packet2));
        mavlink_msg_to_send_buffer(buffer, &msg);
        for (i=0; i<mavlink_msg_get_send_buffer_length(&msg); i++) {
            comm_send_ch(MAVLINK_COMM_0, buffer[i]);
        }
    mavlink_msg_control_decode(last_msg, &packet2);
        MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
        
        memset(&packet2, 0, sizeof(packet2));
    mavlink_msg_control_send(MAVLINK_COMM_1 , packet1.cogoallocation , packet1.coactuallocation , packet1.cogoalangle , packet1.coactualangle , packet1.coX , packet1.coY , packet1.coangle , packet1.cogoalspeed , packet1.coactualspeed , packet1.cogoalaccel , packet1.coactualaccel , packet1.cogoalspinspeed , packet1.coactualspinspeed , packet1.cogoalspinaccel , packet1.coactualspinaccel );
    mavlink_msg_control_decode(last_msg, &packet2);
        MAVLINK_ASSERT(memcmp(&packet1, &packet2, sizeof(packet1)) == 0);
}

static void mavlink_test_equipment(uint8_t system_id, uint8_t component_id, mavlink_message_t *last_msg)
{
    mavlink_test_gyroscope(system_id, component_id, last_msg);
    mavlink_test_magnetometer(system_id, component_id, last_msg);
    mavlink_test_allinlast(system_id, component_id, last_msg);
    mavlink_test_modechoose(system_id, component_id, last_msg);
    mavlink_test_control(system_id, component_id, last_msg);
}

#ifdef __cplusplus
}
#endif // __cplusplus
#endif // EQUIPMENT_TESTSUITE_H
